<?php
/**
 * @param Album $album
 */
$album_id = $album->id;
    $this->pageHeader = t('PAGE_TITLE_PHOTO', 'gallery');
    $this->pageTitle = t('PAGE_TITLE_PHOTO', 'gallery');
    $toolbar = new LGToolbar();
    
    $toolbar->buttonAddNew('480', '530', t('PAGE_TITLE_ADDNEW_PHOTO', 'gallery'), t('BTN_ADDNEW'), 
	    '', true, app()->controller->id.'/createPhoto', 
	    array('album_id' => $model->album_id));
    //$toolbar->addNewHasFile('480', '470', t('PAGE_TITLE_ADDNEW_PHOTO', 'gallery'));
   $toolbar->buttonDelete(t('BTN_DELETE'), '', app()->controller->id . '/deletePhoto');
    //$toolbar->deleteList();
    $toolbar->buttonRefresh(t('BTN_REFRESH'), '', url(app()->controller->id . '/detailRefresh/'.$album_id));
    $this->pageToolbar = $toolbar->mergeToolbar();
    $this->breadcrumbs = array('Management', t('LBL_GALLERY', 'gallery') => array('index')
	, t('LBL_PHOTO', 'gallery'));
//    $themeUrl = Yii::app()->theme->baseUrl;
//    cs()->registerScriptFile($themeUrl . '/js/jquery.validate.js');
?>
<!-- search-form -->
<div class="search-form" >
    <?php
    $this->renderPartial('_searchphoto', array(
        'model' => $model,
	'album_id' => $album_id
    ));
    ?>
</div>

<!-- grid -->
<?php $this->widget('GridView', array(
    'id' => 'DataGrid',
    'dataProvider' => $model->search(LGHelpers::getPageSize()),
     'summaryText' => LGHelpers::getSummary(),
    'columns' => array(
        array(
            'header' => '#',
            'class' => 'CCheckBoxColumn',
            'selectableRows' => '2',
            'id' => 'chkId',
        ),
        array(
            'name' => 'name',
            'sortable' => false,
	    'value' => 'app()->controller->updatePhotoButtonHtml($data, 480, 560)',
	    'type' => 'raw',
        ),
        array(
            'name' => 'picture',
            'value' => 'Html::tag("img", array("src"=> file_exists(MEDIA_FOLDER . DS . "gallery" . DS . $data->picture)? SITE_URL. "/media/gallery/" . $data->picture : SITE_URL. "/media/gallery/no_image.jpg" , 
                "title"=>substr($data->picture, strpos($data->picture, "_") + 1),
                "alt"=>substr($data->picture, strpos($data->picture, "_") + 1), 
                "width"=>"80px", "height"=>"80px"))',
            'htmlOptions' => array('align' => 'center', 'style' => 'width:100px;'),
            'type' => 'raw',
	    'sortable' => false,
        ),
        array(
            'htmlOptions' => array('width' => '29px', 'align' => 'center'),
            'name' => 'status',
            'value' => 'Html::active($data->id, $data->status, "photoStatus")',
            'type' => 'raw',
	    'sortable' => false,
        ),
       array('name' => 'display_order',
	    'value' => 'app()->controller->getHtmlDownButtonForPhoto($data).app()->controller->getHtmlUpButtonForPhoto($data)',
	    'type' => 'raw',
	    'sortable' => false,
	    'htmlOptions' => array(
		'style' => 'width:57px;text-align: center'
	    )),
        array(
            'name' => 'album_name',
            'value' => '$data->album->name',
            'htmlOptions' => array('width' => '114px', 'align' => 'center'),
	    'sortable' => false,
	),
         array(
            'name' => 'updated_by',
            'htmlOptions' => array('align' => 'center','width' => '71px'),
	     'sortable' => false,
        ),
        array(
            'name' => 'update_date',
            'htmlOptions' => array('align' => 'center','width' => '99px'),
            'sortable' => false,
        ),
        array(
            'name' => 'hits',
            'htmlOptions' => array('align' => 'center', 'width' => '29px'),
	    'sortable' => false,
        ),
        array(
            'name' => 'language',
            'htmlOptions' => array('align' => 'center','width' => '57px'),
            'value' => 'LGHelpers::getLanguage($data->language)',
	    'sortable' => false,
        ),
        array(
            'name' => 'id',
            'htmlOptions' => array('align' => 'center', 'width' => '27px'),
        ),
        array('header' => t('LBL_ACTION', 'user'),
                'headerHtmlOptions' => array('width' => '10px', 'style' => 'text-align:center'),
	    'htmlOptions' => array('align' => 'center', 'width' => '27px'),
                'class' => 'ButtonColumn',
                'template' => "{updateHasFile}",
                'buttons' => array(
                    'updateHasFile' => array('title' => t('LBL_EDIT_PHOTO', 'gallery'), 'url' => 'url("gallery/updatePhoto/",array("id"=>$data->id))', 'dialog-width' => '480', 'dialog-height' => '560'),
                )
        ),
    ),
));
?>
<?php $this->widget('ext.EUpdateFileDialog.EUpdateFileDialog', array('dialogOptions' => array('resizable' => false))); ?>
<script>
//$(document).ready(function(){
//    $(":button.button.update-file-dialog-open-link").attr('href','<?php echo url('gallery/createphoto', array('album_id' => $model->album_id)); ?>');
//    var deleteLink = $("#linkDelete").attr('onclick');
//    deleteLink = deleteLink.substring(0,deleteLink.length-1);
//    deleteLink += "+'&isPhoto=1')";
//    $("#linkDelete").attr('onclick',deleteLink);
//});
</script>